﻿using System.Data.Common;
using System.Data.SqlClient;

namespace MaQiu.SqlExecute.DbProvider
{
    public interface IDbProvider
    {
        DbConnection GetConnection(string connectionString);
        DbCommand GetCommand();
        DbParameter Parameter(string name, object value);
    }

    internal class SqlServerProvider : IDbProvider
    {
        public DbConnection GetConnection(string connectionString)
        {
            return new SqlConnection(connectionString);
        }

        public DbCommand GetCommand()
        {
            return new SqlCommand();
        }

        public DbParameter Parameter(string name, object value)
        {
            return new SqlParameter { ParameterName = name, Value = value };
        }
    }
}